// Generated from RuleSet.g4 by ANTLR 4.9
        //一种action,定义生成的词法语法解析文件的头，当使用java的时候，生成的类需要包名，可以在这里统一定义
 package com.taotao.antlr4.sql;
 
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;

@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class RuleSetParser extends Parser {
	static { RuntimeMetaData.checkVersion("4.9", RuntimeMetaData.VERSION); }

	protected static final DFA[] _decisionToDFA;
	protected static final PredictionContextCache _sharedContextCache =
		new PredictionContextCache();
	public static final int
		T__0=1, T__1=2, WS=3, ADD=4, SUB=5, MUL=6, DIV=7, NUMBER=8;
	public static final int
		RULE_calcu = 0;
	private static String[] makeRuleNames() {
		return new String[] {
			"calcu"
		};
	}
	public static final String[] ruleNames = makeRuleNames();

	private static String[] makeLiteralNames() {
		return new String[] {
			null, "'('", "')'", null, "'+'", "'-'", "'*'", "'/'"
		};
	}
	private static final String[] _LITERAL_NAMES = makeLiteralNames();
	private static String[] makeSymbolicNames() {
		return new String[] {
			null, null, null, "WS", "ADD", "SUB", "MUL", "DIV", "NUMBER"
		};
	}
	private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
	public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);

	/**
	 * @deprecated Use {@link #VOCABULARY} instead.
	 */
	@Deprecated
	public static final String[] tokenNames;
	static {
		tokenNames = new String[_SYMBOLIC_NAMES.length];
		for (int i = 0; i < tokenNames.length; i++) {
			tokenNames[i] = VOCABULARY.getLiteralName(i);
			if (tokenNames[i] == null) {
				tokenNames[i] = VOCABULARY.getSymbolicName(i);
			}

			if (tokenNames[i] == null) {
				tokenNames[i] = "<INVALID>";
			}
		}
	}

	@Override
	@Deprecated
	public String[] getTokenNames() {
		return tokenNames;
	}

	@Override

	public Vocabulary getVocabulary() {
		return VOCABULARY;
	}

	@Override
	public String getGrammarFileName() { return "RuleSet.g4"; }

	@Override
	public String[] getRuleNames() { return ruleNames; }

	@Override
	public String getSerializedATN() { return _serializedATN; }

	@Override
	public ATN getATN() { return _ATN; }

	public RuleSetParser(TokenStream input) {
		super(input);
		_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
	}

	public static class CalcuContext extends ParserRuleContext {
		public CalcuContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_calcu; }
	 
		public CalcuContext() { }
		public void copyFrom(CalcuContext ctx) {
			super.copyFrom(ctx);
		}
	}
	public static class DivContext extends CalcuContext {
		public List<CalcuContext> calcu() {
			return getRuleContexts(CalcuContext.class);
		}
		public CalcuContext calcu(int i) {
			return getRuleContext(CalcuContext.class,i);
		}
		public TerminalNode DIV() { return getToken(RuleSetParser.DIV, 0); }
		public DivContext(CalcuContext ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).enterDiv(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).exitDiv(this);
		}
		@Override
		public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
			if ( visitor instanceof RuleSetVisitor ) return ((RuleSetVisitor<? extends T>)visitor).visitDiv(this);
			else return visitor.visitChildren(this);
		}
	}
	public static class AddContext extends CalcuContext {
		public List<CalcuContext> calcu() {
			return getRuleContexts(CalcuContext.class);
		}
		public CalcuContext calcu(int i) {
			return getRuleContext(CalcuContext.class,i);
		}
		public TerminalNode ADD() { return getToken(RuleSetParser.ADD, 0); }
		public AddContext(CalcuContext ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).enterAdd(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).exitAdd(this);
		}
		@Override
		public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
			if ( visitor instanceof RuleSetVisitor ) return ((RuleSetVisitor<? extends T>)visitor).visitAdd(this);
			else return visitor.visitChildren(this);
		}
	}
	public static class NumberContext extends CalcuContext {
		public TerminalNode NUMBER() { return getToken(RuleSetParser.NUMBER, 0); }
		public NumberContext(CalcuContext ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).enterNumber(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).exitNumber(this);
		}
		@Override
		public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
			if ( visitor instanceof RuleSetVisitor ) return ((RuleSetVisitor<? extends T>)visitor).visitNumber(this);
			else return visitor.visitChildren(this);
		}
	}
	public static class SubContext extends CalcuContext {
		public List<CalcuContext> calcu() {
			return getRuleContexts(CalcuContext.class);
		}
		public CalcuContext calcu(int i) {
			return getRuleContext(CalcuContext.class,i);
		}
		public TerminalNode SUB() { return getToken(RuleSetParser.SUB, 0); }
		public SubContext(CalcuContext ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).enterSub(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).exitSub(this);
		}
		@Override
		public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
			if ( visitor instanceof RuleSetVisitor ) return ((RuleSetVisitor<? extends T>)visitor).visitSub(this);
			else return visitor.visitChildren(this);
		}
	}
	public static class ParensContext extends CalcuContext {
		public CalcuContext calcu() {
			return getRuleContext(CalcuContext.class,0);
		}
		public ParensContext(CalcuContext ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).enterParens(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).exitParens(this);
		}
		@Override
		public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
			if ( visitor instanceof RuleSetVisitor ) return ((RuleSetVisitor<? extends T>)visitor).visitParens(this);
			else return visitor.visitChildren(this);
		}
	}
	public static class MulContext extends CalcuContext {
		public List<CalcuContext> calcu() {
			return getRuleContexts(CalcuContext.class);
		}
		public CalcuContext calcu(int i) {
			return getRuleContext(CalcuContext.class,i);
		}
		public TerminalNode MUL() { return getToken(RuleSetParser.MUL, 0); }
		public MulContext(CalcuContext ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).enterMul(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof RuleSetListener ) ((RuleSetListener)listener).exitMul(this);
		}
		@Override
		public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
			if ( visitor instanceof RuleSetVisitor ) return ((RuleSetVisitor<? extends T>)visitor).visitMul(this);
			else return visitor.visitChildren(this);
		}
	}

	public final CalcuContext calcu() throws RecognitionException {
		return calcu(0);
	}

	private CalcuContext calcu(int _p) throws RecognitionException {
		ParserRuleContext _parentctx = _ctx;
		int _parentState = getState();
		CalcuContext _localctx = new CalcuContext(_ctx, _parentState);
		CalcuContext _prevctx = _localctx;
		int _startState = 0;
		enterRecursionRule(_localctx, 0, RULE_calcu, _p);
		try {
			int _alt;
			enterOuterAlt(_localctx, 1);
			{
			setState(8);
			_errHandler.sync(this);
			switch (_input.LA(1)) {
			case T__0:
				{
				_localctx = new ParensContext(_localctx);
				_ctx = _localctx;
				_prevctx = _localctx;

				setState(3);
				match(T__0);
				setState(4);
				calcu(0);
				setState(5);
				match(T__1);
				}
				break;
			case NUMBER:
				{
				_localctx = new NumberContext(_localctx);
				_ctx = _localctx;
				_prevctx = _localctx;
				setState(7);
				match(NUMBER);
				}
				break;
			default:
				throw new NoViableAltException(this);
			}
			_ctx.stop = _input.LT(-1);
			setState(24);
			_errHandler.sync(this);
			_alt = getInterpreter().adaptivePredict(_input,2,_ctx);
			while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
				if ( _alt==1 ) {
					if ( _parseListeners!=null ) triggerExitRuleEvent();
					_prevctx = _localctx;
					{
					setState(22);
					_errHandler.sync(this);
					switch ( getInterpreter().adaptivePredict(_input,1,_ctx) ) {
					case 1:
						{
						_localctx = new MulContext(new CalcuContext(_parentctx, _parentState));
						pushNewRecursionContext(_localctx, _startState, RULE_calcu);
						setState(10);
						if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)");
						setState(11);
						match(MUL);
						setState(12);
						calcu(7);
						}
						break;
					case 2:
						{
						_localctx = new DivContext(new CalcuContext(_parentctx, _parentState));
						pushNewRecursionContext(_localctx, _startState, RULE_calcu);
						setState(13);
						if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)");
						setState(14);
						match(DIV);
						setState(15);
						calcu(6);
						}
						break;
					case 3:
						{
						_localctx = new AddContext(new CalcuContext(_parentctx, _parentState));
						pushNewRecursionContext(_localctx, _startState, RULE_calcu);
						setState(16);
						if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)");
						setState(17);
						match(ADD);
						setState(18);
						calcu(5);
						}
						break;
					case 4:
						{
						_localctx = new SubContext(new CalcuContext(_parentctx, _parentState));
						pushNewRecursionContext(_localctx, _startState, RULE_calcu);
						setState(19);
						if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)");
						setState(20);
						match(SUB);
						setState(21);
						calcu(4);
						}
						break;
					}
					} 
				}
				setState(26);
				_errHandler.sync(this);
				_alt = getInterpreter().adaptivePredict(_input,2,_ctx);
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			unrollRecursionContexts(_parentctx);
		}
		return _localctx;
	}

	public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
		switch (ruleIndex) {
		case 0:
			return calcu_sempred((CalcuContext)_localctx, predIndex);
		}
		return true;
	}
	private boolean calcu_sempred(CalcuContext _localctx, int predIndex) {
		switch (predIndex) {
		case 0:
			return precpred(_ctx, 6);
		case 1:
			return precpred(_ctx, 5);
		case 2:
			return precpred(_ctx, 4);
		case 3:
			return precpred(_ctx, 3);
		}
		return true;
	}

	public static final String _serializedATN =
		"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\n\36\4\2\t\2\3\2"+
		"\3\2\3\2\3\2\3\2\3\2\5\2\13\n\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3"+
		"\2\3\2\3\2\7\2\31\n\2\f\2\16\2\34\13\2\3\2\2\3\2\3\2\2\2\2!\2\n\3\2\2"+
		"\2\4\5\b\2\1\2\5\6\7\3\2\2\6\7\5\2\2\2\7\b\7\4\2\2\b\13\3\2\2\2\t\13\7"+
		"\n\2\2\n\4\3\2\2\2\n\t\3\2\2\2\13\32\3\2\2\2\f\r\f\b\2\2\r\16\7\b\2\2"+
		"\16\31\5\2\2\t\17\20\f\7\2\2\20\21\7\t\2\2\21\31\5\2\2\b\22\23\f\6\2\2"+
		"\23\24\7\6\2\2\24\31\5\2\2\7\25\26\f\5\2\2\26\27\7\7\2\2\27\31\5\2\2\6"+
		"\30\f\3\2\2\2\30\17\3\2\2\2\30\22\3\2\2\2\30\25\3\2\2\2\31\34\3\2\2\2"+
		"\32\30\3\2\2\2\32\33\3\2\2\2\33\3\3\2\2\2\34\32\3\2\2\2\5\n\30\32";
	public static final ATN _ATN =
		new ATNDeserializer().deserialize(_serializedATN.toCharArray());
	static {
		_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
		for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
			_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
		}
	}
}